package common

// Response http的返回地址 */
type Response struct {
	Code    int    `json:"code"`
	Message string `json:"msg"`
}

// ResponseData http的返回地址 */
type ResponseData struct {
	Response
	Data interface{} `json:"data"`
}

// RespError 返回http结果
func RespError(msg string) interface{} {
	return RespResult(500, msg)
}

// RespSuccess 返回http结果
func RespSuccess(msg string) interface{} {
	return RespResult(0, msg)
}

// RespData 返回http结果
func RespData(d interface{}) interface{} {

	result := &ResponseData{
		Response: Response{
			Code:    0,
			Message: "",
		},
		Data: d,
	}

	return result
}

// RespResult 返回http结果
func RespResult(code int, msg string) interface{} {
	resp := Response{
		Code:    code,
		Message: msg,
	}
	return &resp
}
